package com.koron.css2.newProjectCenter.impl;

import com.koron.css2.ServerInterface;
import com.koron.css2.newProjectCenter.bean.PjTerminationBean;
import com.koron.css2.newProjectCenter.mapper.PjTerminationMapper;
import com.koron.css2.serviceManage.bean.RequestBean;
import com.koron.css2.serviceManage.bean.UserInfoBean;
import com.koron.css2.serviceManage.utils.JsonUtils;
import com.koron.util.Constant;
import org.koron.ebs.mybatis.SessionFactory;
import org.swan.bean.MessageBean;

/**
 * 工程管理-单条工程终止信息更新
 * 1. 前端传bean
 */
public class PjTerminationUpdate implements ServerInterface {

    @Override
    public MessageBean<?> exec(SessionFactory factory, UserInfoBean userInfo, RequestBean req) {
        try {
            PjTerminationBean pjTerminationBean = JsonUtils.objectToPojo(req.getData(),PjTerminationBean.class);
            PjTerminationMapper pjTerminationMapper = factory.getMapper(PjTerminationMapper.class);

            // 1. 更新数据
            pjTerminationBean.setUpdateInfo(userInfo);
            pjTerminationMapper.update(pjTerminationBean);
            // 2. 返回结果
            return MessageBean.create(Constant.MESSAGE_INT_SUCCESS, "工程终止单条数据更新成功",null);
        } catch (Exception e) {
            logger.error("工程终止单条数据更新失败",e);
            return MessageBean.create(Constant.MESSAGE_INT_FAIL,"工程终止单条数据更新失败",null);
        }
    }
}
